import 'package:flutter/material.dart';
import 'package:sz/tools/color.dart';

class SWSTextField extends StatelessWidget {
  const SWSTextField({
    Key? key,
    this.controller,
    this.focusNode,
    this.maxLength = TextField.noMaxLength,
    this.keyboardType = TextInputType.text,
    this.hintText,
    this.hintTextColor = const Color(0xffc4c8d0),
    this.fillColor = const Color(0xffe1f3fd),
    this.textColor = const Color(0xff333333),
    this.fontSize = 16.0,
    this.hintFontSize = 16.0,
    this.border = InputBorder.none,
    this.contentPadding =
        const EdgeInsets.symmetric(vertical: 14.0, horizontal: 15.0),
    this.borderRadius = 0,
    this.onChanged,
  }) : super(key: key);

  final int? maxLength;
  final TextEditingController? controller;
  final FocusNode? focusNode;
  final TextInputType? keyboardType;
  final String? hintText;
  final Color? hintTextColor;
  final Color? fillColor;
  final Color? textColor;
  final InputBorder? border;
  final EdgeInsetsGeometry? contentPadding;
  final double fontSize;
  final double hintFontSize;
  final double borderRadius; //圆角
  final ValueChanged<String>? onChanged;

  @override
  Widget build(BuildContext context) {
    return TextField(
      cursorColor: SzColor.c9,
      maxLength: maxLength,
      textAlignVertical: TextAlignVertical.center,
      controller: controller,
      focusNode: focusNode,
      keyboardType: keyboardType,
      style: TextStyle(
        color: textColor,
        fontSize: fontSize,
      ),
      onChanged: onChanged,
      decoration: InputDecoration(
        contentPadding: contentPadding,
        isCollapsed: true,
        border: border,
        counterText: "",
        fillColor: fillColor,
        filled: true,
        enabledBorder: OutlineInputBorder(
            borderSide: const BorderSide(color: Color(0x00FF0000)),
            borderRadius: BorderRadius.all(Radius.circular(borderRadius))),
        hintText: hintText,
        hintStyle: TextStyle(
          color: hintTextColor,
          fontSize: hintFontSize,
        ),
        focusedBorder: OutlineInputBorder(
          borderSide: const BorderSide(color: Color(0x00000000)),
          borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
        ),
      ),
    );
  }
}
